const fs = require('fs')
// 异步
fs.readFile('./清平调.md', (err, data) => {
    // console.log(res.toString() ,err);
    console.log(data.toString(),err,'异步');
})
// 同步
const data = fs.readFileSync('./清平调.md');
console.log(data.toString(),'同步');

// 文件复制
const cope = fs.readFileSync('./文档/01_Buffer.pdf') 
fs.writeFileSync('./01_Buffer_cope.pdf',cope)

// 流式复制
const rs = fs.createReadStream('./文档/01_Buffer.pdf')
const ws = fs.createWriteStream('./01_Buffer_cope_1.pdf')
rs.on('data',chunk => {
    console.log(chunk.length);
    ws.write(chunk);
})
